import request from "@/utils/request";
import { AxiosPromise } from "axios";
import { ApprovalOptions, ApprovalPage, ApprovalQuery } from "./types";

export function getOptions(): AxiosPromise<ApprovalOptions[]> {
  return request({
    url: "/admin/approval/getOptions",
    method: "get",
  });
}

/**
 * 获取分页列表
 *
 * @param queryParams
 */
export function getSendCopyPage(
  queryParams: ApprovalQuery
): AxiosPromise<PageResult<ApprovalPage[]>> {
  return request({
    url: "/admin/sendCopy/index",
    method: "get",
    params: queryParams,
  });
}

/**
 * 获取分页列表
 *
 * @param queryParams
 */
export function getTacklePage(
  queryParams: ApprovalQuery
): AxiosPromise<PageResult<ApprovalPage[]>> {
  return request({
    url: "/admin/sendCopy/tackle",
    method: "get",
    params: queryParams,
  });
}

export function approvalHandle(data: any) {
  return request({
    url: "/admin/sendCopy/handle",
    method: "post",
    data: data,
  });
}

export function approvalIsRead(data: any) {
  return request({
    url: "/admin/sendCopy/isRead",
    method: "post",
    data: data,
  });
}

/**
 * 获取表单详情
 *
 * @param ids
 */
export function getApprovalForm(ids: number): AxiosPromise<ApprovalPage> {
  return request({
    url: "/admin/sendCopy/edit",
    method: "get",
    params: {
      ids: ids,
    },
  });
}
